Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. DF=data.frame(y=c(182.00455,606.27273,2401.03918,1597.27500,179.68846,76.82728,313.85000,1431.00000,16.43620,22887.81818,1010.00000,20.65909,184.17273,483.35000,21.45000,291.01500,359.10000,602.75000,253.18636,35.74286),
  2. x=c(133.955464,1.913142,88.887131,95.512793,25.247257,11.938203,51.246909,96.265030,42.701863,9.082072,42.466148,86.741979,15.908011,55.756779,79.432585,61.395584,22.822762,22.853197,30.154734,96.494249))
  3.  
  4. fit <- lm(log(y) ~ log(x), data=DF)
  5. summary(fit)
  6.  
  7. prediction=predict.lm(fit, interval="confidence")
  8.  
  9. prediction=data.frame(prediction)
  10. prediction=exp(prediction) # Since the model was built using log, the values are exponentiated before use.
  11. prediction$halfwidth=(prediction$upr-prediction$lwr)/2
  12. prediction$error_squared=prediction$halfwidth^2
  13.  
  14. sqrt(sum(prediction$error_squared, na.rm=T))
  15.  
  16. sum(prediction$fit)
  17.  
  18. ## uncertainty percentage:
  19. (sqrt(sum(prediction$error_squared, na.rm=T))/sum(prediction$fit))*100
  20. # [1] 108.656%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement