GENDER,AGE,MARSTAT,EDUCATION,ETHNICITY,SMARSTAT,SGENDER,SAGE,SEDUCATION,NUMHH,INCOME,TOTINCOME,CHARITY,FACE,FACECVLIFEPOLICIES,CASHCVLIFEPOLICIES,BORROWCVLIFEPOL,NETVALUE...

1 answer below »
Please answer all the questions and include the code and output in R. Thank you so much!


GENDER,AGE,MARSTAT,EDUCATION,ETHNICITY,SMARSTAT,SGENDER,SAGE,SEDUCATION,NUMHH,INCOME,TOTINCOME,CHARITY,FACE,FACECVLIFEPOLICIES,CASHCVLIFEPOLICIES,BORROWCVLIFEPOL,NETVALUE 1,30,1,16,3,2,2,27,16,3,43000,43000,0,20000,0,0,0,0 1,50,1,9,3,1,2,47,8,3,12000,0,0,130000,0,0,0,0 1,39,1,16,1,2,2,38,16,5,120000,90000,500,1500000,0,0,0,0 1,43,1,17,1,1,2,35,14,4,40000,40000,0,50000,75000,0,5,0 1,61,1,15,1,2,2,59,12,2,25000,1020000,500,0,7000000,300000,5,0 1,34,2,11,2,1,2,31,14,4,28000,0,0,220000,0,0,0,0 0,75,0,8,1,0,0,0,0,1,2500,0,0,0,14000,5000,5,0 1,29,1,16,1,2,2,31,17,3,100000,84000,0,600000,0,0,0,0 1,35,2,4,3,1,2,45,9,2,20000,0,0,0,0,0,0,0 1,70,1,17,1,2,2,74,16,2,101000,6510000,284000,0,2350000,0,5,0 1,72,1,17,1,2,2,70,14,2,112000,8460000,12000,100000,0,0,0,0 1,51,1,16,1,2,2,52,14,4,15000,300000,10000,2500000,200000,37000,1,3 1,23,0,14,1,0,0,0,0,4,11000,0,0,0,0,0,0,0 1,58,0,14,1,0,0,0,0,1,32000,0,0,250000,0,0,0,0 1,36,1,16,1,2,2,33,12,2,57000,33000,7300,0,354000,1700,5,0 1,58,1,14,1,2,2,50,12,4,220000,230000,1200,0,400000,40000,5,0 1,73,1,12,2,2,2,65,16,2,25000,41000,1000,50000,0,0,0,0 0,50,0,12,1,0,0,0,0,2,20000,0,0,0,0,0,0,0 1,35,2,12,2,1,2,31,12,6,40000,0,0,90000,40000,950,5,0 0,26,0,14,1,0,0,0,0,2,25000,0,0,0,0,0,0,0 1,60,1,16,1,2,2,55,14,2,66000,66000,1200,10000,0,0,0,0 1,46,2,17,1,3,1,37,16,4,120000,196000,0,2000000,500000,5000,5,0 0,43,0,13,2,0,0,0,0,3,13000,0,0,50000,0,0,0,0 1,36,2,9,3,3,2,24,8,5,17000,17000,0,0,0,0,0,0 1,50,1,14,1,2,2,47,16,2,34000,35000,0,0,0,0,0,0 1,50,1,17,1,2,2,49,16,2,200000,160000,3500,1500000,0,0,0,0 1,56,0,14,2,0,0,0,0,1,50000,0,0,150000,0,0,0,0 1,30,2,12,7,1,2,41,12,3,50000,0,1000,0,0,0,0,0 1,43,1,12,1,2,2,41,14,5,56000,57000,0,0,0,0,0,0 1,32,1,7,3,1,2,42,9,4,45000,45000,0,100000,0,0,0,0 0,57,0,13,1,0,0,0,0,1,2300,0,0,0,0,0,0,0 1,27,0,16,7,0,0,0,0,1,80000,0,0,0,0,0,0,0 0,64,0,13,1,0,0,0,0,1,42000,0,600,60000,10000,0,5,0 1,62,0,16,1,0,0,0,0,1,225000,0,4000,1100000,0,0,0,0 1,61,1,17,1,2,2,59,17,2,102000,357000,3400,30000,0,0,0,0 0,54,0,13,7,0,0,0,0,7,34000,0,1200,100000,0,0,0,0 1,61,1,17,2,2,2,63,16,2,1200000,21880000,191000,0,35000000,7000000,5,0 0,60,0,17,1,0,0,0,0,1,70000,0,800,75000,75000,16000,5,0 1,47,1,16,7,1,2,44,14,5,85000,85000,600,0,0,0,0,0 1,30,1,17,1,2,2,31,17,2,270000,150000,2500,1000000,1000000,4000,5,0 1,52,1,16,1,1,2,52,17,2,292000,365000,1000,1000000,0,0,0,0 1,57,1,16,1,2,2,60,0,1,85000,0,1000,0,20000,15000,5,0 1,65,0,14,1,0,0,0,0,1,13000,0,0,0,0,0,0,0 1,60,1,13,1,2,2,41,14,3,95000,100000,2000,200000,10000,600,5,0 1,43,1,17,1,2,2,40,17,6,7870000,10820000,509000,2700000,0,0,0,0 1,55,1,17,1,2,2,61,12,2,105000,106000,2300,150000,15000,8400,5,0 1,50,1,16,1,2,2,49,17,4,90000,90000,0,102000,450000,50000,5,0 1,56,0,17,1,0,0,0,0,1,12000,0,0,0,0,0,0,0 1,34,1,16,1,1,2,38,16,5,84000,85000,0,400000,0,0,0,0 1,50,1,12,1,2,2,43,15,3,93000,128000,0,500000,0,0,0,0 1,56,1,17,3,2,2,56,16,4,155000,300000,10000,900000,1000000,13000,5,0 1,39,1,14,1,1,2,47,13,2,131000,266000,10000,0,0,0,0,0 1,50,1,16,1,2,2,42,16,4,52000,94000,2000,0,100000,16000,5,0 1,45,1,14,1,1,2,43,14,6,82000,50000,0,0,200000,46000,5,0 1,26,1,12,3,2,2,26,12,4,45000,0,0,0,0,0,0,0 1,38,1,14,1,2,2,39,13,3,42000,28000,0,0,0,0,0,0 0,44,0,8,2,0,0,0,0,5,9000,0,0,0,0,0,0,0 1,58,1,17,1,2,2,57,17,2,170000,215000,2000,75000,0,0,0,0 1,42,1,13,1,2,2,40,12,4,53000,53000,500,10000,49000,5800,5,0 1,37,1,12,1,2,2,50,17,2,110000,0,700,100000,60000,30000,1,2 1,62,1,17,1,2,2,61,16,2,200000,310000,10000,1500000,0,0,0,0 0,40,0,16,1,0,0,0,0,3,42000,0,0,0,100000,150,5,0 0,44,0,12,2,0,0,0,0,1,13000,0,0,0,0,0,0,0 1,49,1,14,1,1,2,48,14,5,105000,113000,0,50000,0,0,0,0 1,56,0,14,1,0,0,0,0,1,58000,0,0,200000,0,0,0,0 1,64,1,17,1,2,2,62,16,2,240000,380000,10000,50000,30000,25000,1,3 1,46,1,12,1,2,2,42,12,4,280000,1500000,50000,0,2000000,250000,5,0 1,54,1,14,1,2,2,51,14,3,84000,86000,1000,0,0,0,0,0 1,48,1,16,1,2,2,44,14,2,58000,59000,1200,50000,4000,4000,5,0 1,52,1,16,1,1,2,58,16,3,60000,72000,1200,400000,0,0,0,0 1,48,2,10,1,1,2,42,12,4,52000,0,0,50000,0,0,0,0 1,26,1,17,1,2,2,25,17,2,25000,0,0,0,0,0,0,0 1,41,1,16,1,2,2,33,16,4,45000,49000,0,1200000,525000,5000,5,0 0,38,0,14,2,0,0,0,0,1,30000,0,0,0,0,0,0,0 0,50,0,12,2,0,0,0,0,2,16000,0,0,0,0,0,0,0 1,29,1,12,2,2,2,28,16,4,40000,0,0,100000,0,0,0,0 1,45,1,17,1,2,2,42,14,2,75000,732000,1000,0,0,0,0,0 1,23,0,16,1,0,0,0,0,1,6000,0,0,0,0,0,0,0 1,68,1,17,1,2,2,66,17,2,300000,1700000,180000,0,5000000,206000,1,3 1,26,1,16,1,1,2,22,14,3,80000,80000,0,0,0,0,0,0 1,40,1,16,1,2,2,34,14,4,91000,93000,2900,400000,0,0,0,0 1,62,1,12,2,1,2,58,14,3,37000,57000,500,0,40000,2000,5,0 1,28,1,16,1,2,2,25,14,2,27000,49000,0,40000,0,0,0,0 1,48,1,16,1,2,2,48,16,3,50000,2320000,17000,0,1500000,34000,5,0 1,33,1,15,1,2,2,31,17,4,155000,155000,4000,700000,0,0,0,0 1,52,1,17,1,2,2,51,17,2,164000,2460000,331000,0,0,0,0,0 0,46,0,12,2,0,0,0,0,2,7400,0,0,0,13000,100,5,0 1,74,1,16,1,2,2,73,14,2,2730000,10120000,9010000,0,200000,60000,5,0 1,42,1,14,1,1,2,43,16,4,102000,112000,8000,360000,0,0,0,0 0,53,2,12,2,3,1,52,0,1,530,0,0,0,0,0,0,0 1,59,1,17,1,1,2,53,17,2,30000,78000,0,180000,1000000,900,5,0 1,40,1,17,1,2,2,40,17,3,190000,250000,2000,200000,0,0,0,0 1,52,1,17,1,2,2,52,17,5,1700000,3200000,332000,0,500000,450000,5,0 1,68,0,15,1,0,0,0,0,2,110000,0,3500,0,1600000,250000,5,0 1,38,1,16,1,1,2,35,16,4,63000,46000,1400,100000,50000,10000,5,0 1,58,1,13,1,1,2,58,12,2,58000,58000,2000,26000,55000,4000,5,0 1,70,1,14,1,2,2,67,12,2,155000,216000,1600,0,400000,100000,5,0 1,50,1,17,1,2,2,52,14,4,167000,5800000,232000,0,300000,34000,5,0 1,62,2,12,2,1,2,52,12,2,41000,0,500,20000,0,0,0,0 1,45,1,16,1,2,2,42,17,7,500000,563000,8500,2000000,2000000,20000,5,0 1,24,0,14,1,0,0,0,0,3,34000,0,1000,0,130000,6300,5,0 1,31,0,11,2,0,0,0,0,1,5000,0,0,0,0,0,0,0 1,47,1,17,1,2,2,48,17,4,90000,500000,20000,2500000,150000,20000,5,0 1,48,0,13,2,0,0,0,0,1,40000,0,0,50000,0,0,0,0 1,31,0,16,1,0,0,0,0,1,90000,0,3000,0,750000,80000,5,0 1,35,0,16,1,0,0,0,0,1,43000,0,0,41000,0,0,0,0 1,47,1,12,1,2,2,43,12,5,50000,101000,12000,0,0,0,0,0 1,29,1,15,2,2,2,24,14,4,63000,60000,1200,0,0,0,0,0 1,54,1,16,1,1,2,50,12,2,90000,92000,0,110000,0,0,0,0 1,49,1,13,1,2,2,47,14,3,72000,59000,0,115000,0,0,0,0 0,57
Answered 1 days AfterApr 01, 2021

Answer To: GENDER,AGE,MARSTAT,EDUCATION,ETHNICITY,SMARSTAT,SGENDER,SAGE,SEDUCATION,NUMHH,INCOME,TOTINCOME,CHARI...

Sudharsan.J answered on Apr 02 2021
137 Votes
part-1-corr-scatter-plot-g4jk2fcq.png
part-5-fitted-vs-predicted-1yqi5rvq.png
part-1-boxplot-2-03vzl4mq.png
part-1-boxplot-1-dxm31eds.png
rcode-35q43swq.r
######################### PART-1 #######################
set.seed(1)
x1<- runif (100)
x2<- 0.5* x1+rnorm (100) /10
y<- 2+2* x1 +0.3* x2+rnorm (100)
corr=cor(x1,x2)
plot(x1, x2, main = " Scatter Plot X1 vs X2",
ylab = "Frequency",
pch = 19)
text(paste("Correlation:", round(corr,
2)), x =0.2, y = 4.5)
Linear_model=glm(y~x1+x2)
Linear_model
x3 <- c(x1 , 0.1)
x4 <- c(x2 , 0.8)
y1 <- c(y,6)
Linear_model_2=glm(y1~x3+x4)
Linear_model_2
install.packages("ggplot2")
library("ggplot2")
data=data.frame(y,x1,x2)
data1=data.frame(y1,x3,x4)
plot_1=boxplot(data,
col = c("red", "green", "purple"))
plot_2=boxplot(data1,
col = c("pink", "light green", "dark gray"))
######################### PART-2 #######################
library(UsingR)
kid_data=as.data.frame(data(kid.weights))
data(kid.weights)
attach(kid.weights)
plot(weight,height,pch=as.character(gender))
str(kid.weights)
kid.weights$height_2=height^2
kid.weights$height_3=height^3
kid.weights$height_4=height^4
Linear_model_3=glm(weight~age+height+height_2+height_3+height_4,data = kid.weights)
Linear_model_3
######################### PART-3 #######################
data_3=read.csv("C:\\Users\\sudharsan\\Desktop\\Greynodes\\79262\\termlife.csv")
timelife=subset(data_3,FACE>0)
timelife$LNFACE=log(timelife$FACE)
timelife$LNINCOME=log(timelife$INCOME)
str(timelife)
Linear_model_4=glm(LNFACE~LNINCOME+EDUCATION+NUMHH+MARSTAT+AGE+GENDER,data = timelife)
Linear_model_4
summary(Linear_model_4)
vif(Linear_model_4)
Linear_model_5=glm(LNFACE~LNINCOME+EDUCATION+NUMHH+AGE+GENDER,data = timelife)
Linear_model_5
summary(Linear_model_5)
vif(Linear_model_5) #better result after removing MARSTAT, due to multicollinearity
library(ppcor)
pcor(timelife[,c(1:4,10,19,20)],method="pearson")$estimate
######################### PART-4 #######################
condo=read.csv("C:\\Users\\sudharsan\\Desktop\\Greynodes\\79262\\condo.csv")
str(condo)
Linear_model_5=lm(price~condo+sqfeet,data = condo)
Linear_model_5
summary(Linear_model_5)
Linear_model_6=lm(price~condo+sqfeet+condo*sqfeet,data = condo)
Linear_model_6
summary(Linear_model_6) #best based on AIC and R-square
Linear_model_7=glm(price~condo+sqfeet,data = condo)
summary(Linear_model_7)
Linear_model_8=glm(price~condo+sqfeet+condo*sqfeet,data = condo)
summary(Linear_model_8)
corr1=cor(condo$sqfeet,condo$price)
corr1
######################### PART-5 #######################
library(UsingR)
data("fat")
attach(fat)
str(fat)
set.seed(25)
data2 = sort(sample(nrow(fat), nrow(fat)*.7))
train<-fat[data2,]
test<-fat[-data2,]
Linear_model_9=lm(bodyfat~abdomin+biceps+forearm+wrist,data = fat)
Linear_model_9
summary(Linear_model_9)
library(MASS)
library(car)
stepAIC(Linear_model_9,direction = "both")
datasets::fat
Linear_model_10=glm(bodyfat~abdomin+forearm+wrist,data = fat)
Linear_model_10
# 1. Add predictions
pred.int <- as.data.frame(predict(Linear_model_9, newdata = test,interval = "prediction"))
mydata <- cbind(test, pred.int)
# 2. Regression line + confidence intervals
library("ggplot2")
p <- ggplot(test, aes(x = test$bodyfat, y = pred.int$fit)) +
geom_point() +
stat_smooth(method = lm)
# 3. Add prediction intervals
p + geom_line(aes(y = pred.int$lwr), color = "red", linetype = "dashed")+
geom_line(aes(y = pred.int$upr), color = "red", linetype = "dashed")

str(pred.int)
result-output-1qfj0lmx.docx
1) a)
> corr
[1] 0.835121
b) Linear_model=glm(y~x1+x2)
The fitted equation of the best model is:
 Y=2.13 + 1.44*x1 + 1.01*x2
Where b0=2.13 , b1=1.44 and b2=1.01
c)
The fitted least squares regression to predict y if β1 = 0 is Y=2.13 +1.01*x2
d)
The fitted least squares regression to predict y if β2 = 0 is Y=2.13 +1.44*x1
e)
The results obtained in c) and d) are not contradicting each other.
f)
> Linear_model_2=glm(y1~x3+x4)
> Linear_model_2
Call: glm(formula = y1 ~ x3 + x4)
Coefficients:
(Intercept) x3 x4
2.2267 0.5394 2.5146
Degrees of Freedom: 100 Total (i.e. Null); 98 Residual
Null Deviance:     144.9
Residual Deviance: 113.2     AIC: 306.1
The fitted equation of the best model is:
 Y=2.227 + 0.5394*x3 + 2.5146*x4
Where b0=2.227, b1=0.5394 and b2=2.5146

Boxplot-1 (Model-1)                            Boxplot-2 (Re-model)
There was an...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here