You are on page 1of 5

#Que 1.

life <- read.csv("C:/Users/ai-01/Downloads/LifeCycleSavings.csv")


plot(life$sr , life$pop15)
cor(life$sr , life$pop15)

fitLM <- lm(sr ~ pop15 , data =life)


fitLM

typeof(fitLM)
class(fitLM)
names(fitLM)

plot(life$sr , life$pop15+1)
abline(fitLM,col="red")

anova(fitLM)
summary(fitLM)

fitAll <- lm(sr ~ . ,data = life)


fitLM

typeof(fitAll)
class(fitAll)
names(fitAll)

plot(life$sr , life$pop15+1)
abline(fitAll,col="red")

anova(fitAll)
summary(fitAll)
# d. generate histogram ###############
hist(life$dpi)
#############
require(stats);
require(graphics)

######fiting regression on the dataset#################


pairs(LifeCycleSavings, panel = panel.smooth,
main = "LifeCycleSavings data")

###########equation of regressin###############
fm1 <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
#R-squared,Residual-error,p-value
summary(fm1)

#1
1-pbinom(69,71,0.94,lower.tail=TRUE,log.p=FALSE)

mean=71*0.25
variance=71*0.25*0.06
sdev = sqrt(variance)
#2
p_mathandsci=40/100
p_mathandsci
Pm= 60/100
p_m=0.6

prob_of_studymath=p_mathandsci/P_m
prob_of_studymath

#Que
2.***********************************************************************************************************
*******
items <- read.csv("C:/Users/ai-01/Downloads/PlantGrowth.csv")

# split three dataset


ctrl=items[1:10 , ] # only 2nd row
ctrl

trt1=items[11:20 , ]
trt1

trt2=items[21:30 , ]
trt2

#mean on the Weight


mean(ctrl$weight,na.rm = TRUE)
mean(trt1$weight,na.rm = TRUE)
mean(trt2$weight,na.rm = TRUE)

#graph

ggplot(items, aes(x=items$weight,y=items$group))+
geom_boxplot(fill=c("red","green","blue"))

ggplot(items, aes(x=items$weight,y=items$group))+
geom_boxplot()

fitLM <- lm(weight ~ group , data =items)


fitLM
require(stats);
require(graphics);
############generate graph###################
boxplot(weight ~ group, data = PlantGrowth, main = "PlantGrowth data",
ylab = "Dried weight of plants", col = "lightgray",
notch = FALSE, varwidth = TRUE)

######## mean and coefficients of variation############


anova(lm(weight ~ group,data = PlantGrowth))

You might also like