Basically, you are looking at regression model ie using lm
in R. However to use it, you need to have a y
variable. So based on the given x
and y
, the model will learn beta
ie coefficients which gives the best result, in this case Rˆ2
.
So, in case you don't have a y
and want to use the above equation, you can write a simple function, something like:
compute_y = function(intercept = 38, x=70, coefficient){
y <- intercept + (coefficient * x)
sdev <- sd(y)
return(list(y = y, sdev= sdev))
}
y1 <- compute_y(coefficient=0.067)
y2 <- compute_y(coefficient=0.047)
This should give the y
values. However, to calculate standard deviation, you need a vector of x or y values, you can't calculate sd
for a scalar value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.