# Too many coefficients in regression

Solution for Too many coefficients in regression
is Given Below:

I have a data frame with about 800 points in it. The table looks roughly like this:

V4 V92
.5 .02
.25 .12
.5 1.02
.45 -.02
.5 .32
1.5 .42

This goes on for about 850 rows.

I ran a linear regression for this using the code:

``````lmMRE <- lm(data.frame\$V92~data.frame\$V4)
``````

For some reason, when I run this code, my regression has 157 coefficients.

Why might this be? How do I change this so I only have 1?

Thanks!

There is clearly something wrong with your input data. Simulating your data gives the expected one coefficient. Check that both your dependent and independent data are numeric.

See code below.

``````library(tidyverse)

#create fake data
my_data <- data.frame("V4" = 1:800 + rnorm(800, 0, 2),
"V92" = seq(from = 1, to = 100, length.out = 800) )

#run regression
lmMRE <- lm(my_data\$V92~my_data\$V4)

#one coefficient
lmMRE

my_data %>%
ggplot(aes(x = V4, y = V92)) +
geom_point()+
geom_smooth(method=lm) +
labs(title = "Sample regression",
subtitle = paste0("Number of coefficients: ",
length(lmMRE\$coefficients) - 1))
``````

Sample Regression