R regression analysis (single regression)

x <- c(18,23,25,35,65,54,34,56,72,19) # build X(predictor)
y <- c(202,168,180,156,169,174,172,153,199,193) # build Y(dependent variable)
mode(x) # view the type of x
plot(x,y) # plot the graph
model <- lm(y ~ x) # build the linear model
abline(model) # add the line in graph

 

Data is their series, so the map a little fake.

summary(model)

 

 Pictured on various parameters, there are a variety of tests.

 

If you want the output of the model is built, then the equation, the following manner may, of course, also be used Predict () function

pridict <- model$coefficients[1] + model$coefficients[1]*100 # we can pridict 100 in model through this way
print(pridict) # print result

 

 

Guess you like

Origin www.cnblogs.com/zijidefengge/p/11939428.html