title: Data wrangling for linear regression in r
body: <p>I'm attempting to run a linear regression in r using the lm() function but I get various errors however I change my data. I want to see if parental gender, child gender and parent score predict child score. My code is:</p>
  
  <pre><code>mod1 &lt;- lm(score_child ~ score_parent*parent_child*female_male, data=dat, na.action = na.pass)
  </code></pre>
  
  <p>data currently looks something like this:</p>
  
  <pre><code>Subject   Family_number  female_male   parent_child  score_child   score_parent 
  1         1               1             0             230           NA
  2         1               0             1             NA            400
  3         1               0             0             450           NA
  4         2               1             1             NA            500
  5         2               1             0             500           NA                
  .
  </code></pre>
  
  <p>I understand this would be easier to do if the data was in long format however, as I need to separate child and parent score, I thought this was the best way. The NAs give me a lot of grief and I've tried every na.action command but I get errors such as Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 
    NA/NaN/Inf in 'x'.</p>
  
  <p>Would the beast approach be to change the NA command in lm(), change the layout of my data and if so, to what and how would I then specify child and parent score in lm()?</p>
  
  <p>Bonus question; these children any parents are part of families and I would ideally like to analyse the data in family groups. Would that require one regression per family and if so, wouldn't that effect my confident interval?</p>
  
  <p>My dissertation and myself would greatly appreciate any help!</p>
  
  <p>Julia      </p>