0

So I have been trying to decipher some code but have hit a roadblock. can someone please explain to me the what is being done to P$L to get P$HY to get column Y.

I need to understand Functionally (visually how the data frame changes) and from a Mathematical point of view.

Thanks in advance

# create sample data frame 
L <- c(15,12,9,6,3,0)
HY <- c(0,0.106,0.277,0.641,0.907,1)
P <- data.frame(L,Y)

# constants
d <- 5

# THIS IS THE PART THAT I DO NOT UNDERSTAND!!
Y <- lm(P$HY ~ poly(P$L, d))

So it re-iterate the question I´m trying to figure out, mathematically and functionally, what Y <- lm(HY ~ poly(L, d)) is doing.

massisenergy
  • 1,764
  • 3
  • 14
  • 25

1 Answers1

0

You are building a linear model with HY as the dependent variable and L as the independent variable using a polynomial of degree 5 for L, so 5 terms for this variable. You are saving this model in the variable Y.

user2974951
  • 9,535
  • 1
  • 17
  • 24