0

I tried to run a bivariate regression. I want to examine the association between level of education (IV) with views on immigration (DV). The DV is an interval level variable and the IV a dummy variable. I label the regression as reg. The code is as follows:

>reg <-lm(immig.view~edu.degree.level,df1)
>Error in model.frame.default(formula = immig.view ~ edu.degree.level,  : 
variable lengths differ (found for 'edu.degree.level')

I'm completely stuck. Thanks for your help!

Mr.Rlover
  • 2,523
  • 3
  • 14
  • 32
  • 1
    can you dput(head(df1,10)) and paste the output as part of your post? then others can reproduce the error and suggest where the problem lies – StupidWolf Apr 07 '20 at 21:11
  • 1
    Likely one of the variables in your formula is a column of `df1` and the other is a separate vector with different length. – Karolis Koncevičius Apr 07 '20 at 21:12
  • @KarolisKoncevičius exactly this! Many thanks! – Honey Badger Apr 08 '20 at 08:08
  • 1
    @StupidWolf I started over and now the model runs. Many thanks for the suggestion (and also showing me a new command) as I will do this going forward (this was my first post). – Honey Badger Apr 08 '20 at 08:09

0 Answers0