Which package do I need to install to use Lm? (linear model)

If you mean lm(), it is part of the stats package, which I believe any standard installation has. What error or problem are you encountering that leads to this question?

I'm trying to find a linear equation that fits the data shown between X and Y values. I thought I could use lm(X~Y) but an error occurs:

'Error in model.frame.default(formula = X ~ Y, drop.unused.levels = TRUE) : variable lengths differ (found for 'Y')'

The error says that X and Y have different lengths. Use

```
length(X)
length(Y)
```

to check their lengths. They must be equal.

Also, note that lm(X~Y) will return information about modeling X as a function of Y. Is that what you want?

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.