Docsity

R Statistics Assignment Solutions by Bhavya Gupta, Assignments of Probability and Statistics

Toggle sidebar
bg1
Name: Bhavya Gupta
Roll No: 101903215
Group: 2CO8
Assignment - 9
Ques 1:
getwd()
setwd("E:\\SEM-5 Thapar\\Probability_Statistics")
df <- read.csv("turnout.csv",sep=",",header=TRUE)
df1 <- sample(nrow(df),nrow(df)*0.7) #70% training data
train <- df[df1,]
test <- df[-df1,]
actual <- test[,5] #dependent variable column of test data
predicted <- lm(income ~ age + education, data=train)
p <- predict(predicted,test)
rmse <- function(actual,predicted)
{
a<-(actual-predicted)**2
m<-mean(a)
sqrt(m)
}
pf3

Partial preview of the text

Download R Statistics Assignment Solutions by Bhavya Gupta and more Assignments Probability and Statistics in PDF only on Docsity!

Name: Bhavya Gupta Roll No: 101903215 Group: 2CO

Assignment - 9

Ques 1:

getwd() setwd("E:\SEM-5 Thapar\Probability_Statistics") df <- read.csv("turnout.csv",sep=",",header=TRUE)

df1 <- sample(nrow(df),nrow(df)*0.7) #70% training data train <- df[df1,] test <- df[-df1,]

actual <- test[,5] #dependent variable column of test data predicted <- lm(income ~ age + education, data=train) p <- predict(predicted,test)

rmse <- function(actual,predicted) { a<-(actual-predicted)** m<-mean(a) sqrt(m) }

rmse(p,actual) plot(predicted)

Output –

Ques 2:

x <- runif(1000, min=10, max=33)