Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linear Regression and log-log Transformation
#R version 3.3.2 # Let's see the variables head(cars) #Let's see descriptive statistics summary(cars) #Let's see standard deviation as well print(apply(cars,2,sd)) #do te same thing for log transformation of variables lncars <- log(cars) summary(lncars) print(apply(lncars,2,sd)) #plot variables scatter.smooth(x=cars$speed, y=cars$dist, main="Dist ~ Speed") #run a regressio using original data original <- lm(dist ~ speed, data=cars) summary(original) #get predicted y cars$predicted <- predict(original) #Plot actual vs predicted library(ggplot2) ggplot(cars, aes(x = speed, y = dist)) + geom_smooth(method = "lm", se = FALSE, color = "lightgrey") + # Plot regression slope geom_segment(aes(xend = speed, yend = predicted), alpha = .2) + # alpha to fade lines geom_point() + geom_point(aes(y = predicted), shape = 1) + theme_bw() #run a regressio using log transformation of data scatter.smooth(x=lncars$speed, y=lncars$dist, main="lnDist ~ lnSpeed") loglog <- lm(dist ~ speed, data=lncars) summary(loglog) #get predicted y lncars$predicted <- predict(loglog) #Plot actual vs predicted ggplot(lncars, aes(x = speed, y = dist)) + geom_smooth(method = "lm", se = FALSE, color = "lightgrey") + # Plot regression slope geom_segment(aes(xend = speed, yend = predicted), alpha = .2) + # alpha to fade lines geom_point() + geom_point(aes(y = predicted), shape = 1) + theme_bw()
run
|
edit
|
history
|
help
0
AED 6
Chapter 1:Hiring Discrimination
10-08-2020Exe
Gamma
16-09-2020IntPoli
Chi-squared tests of independence [Seat Belt Yes/No] worked
Rcode1
Mietflächen clustern für flächenbasierte Prognosen
Graph
law of large numbers