 It's very interesting that the names of tmp has only 14 items, and the
dim(tmp) shows 14 columns too, but actually the number of columns in tmp
should be 16...

This is very strange...

> dim(X)

[1] 7185 3

> dim(MathScores)

[1] 7185 12

> dim(tmp)

[1] 7185 14


> names(tmp)

[1] "School" "Minority" "Sex" "SES" "MathAch" "MEANSES.x"

[7] "Size" "Sector" "PRACAD" "DISCLIM" "HIMINTY" "MEANSES.y"

[13] "y" "X"




On Sun, May 13, 2012 at 3:30 PM, Michael <comtech.usa@gmail.com> wrote:

> Thank you!
>
> But the line you cited was about "response" being a matrix, which is not
> our case.
>
> And also I have checked:
>
> Any more thoughts?
>
> Thank you!
>
> >
> names(tmp)
>
> [1] "School" "Minority" "Sex" "SES" "MathAch" "MEANSES.x"
>
> [7] "Size" "Sector" "PRACAD" "DISCLIM" "HIMINTY" "MEANSES.y"
>
> [13] "Intercept" "y" "X"
>
> >
> names(MathScores)
>
> [1] "School" "Minority" "Sex" "SES" "MathAch" "MEANSES.x"
>
> [7] "Size" "Sector" "PRACAD" "DISCLIM" "HIMINTY" "MEANSES.y"
>
>
> >
> class(tmp)
>
> [1] "data.frame"
>
> >
> head(tmp)
>
> School Minority Sex SES MathAch MEANSES.x Size Sector PRACAD
>
> 1 1224 No Female -1.52800000 5.876 -0.428 842 Public 0.35
>
> 2 1224 No Female -0.83155757 19.708 -0.428 842 Public 0.35
>
> 3 1224 No Male -0.91452283 20.349 -0.428 842 Public 0.35
>
> 4 1224 No Male -1.33600000 8.781 -0.428 842 Public 0.35
>
> 5 1224 No Male -0.35329874 17.898 -0.428 842 Public 0.35
>
> 6 1224 No Male 0.05388877 4.583 -0.428 842 Public 0.35
>
> DISCLIM HIMINTY MEANSES.y Intercept y X.(Intercept) X.SES
>
> 1 1.597 0 -0.428 1.000000 5.87600 1.00000000 -1.52800000
>
> 2 1.597 0 -0.428 1.414214 27.87132 1.41421356 -0.83155757
>
> 3 1.597 0 -0.428 1.732051 35.24550 1.73205081 -0.91452283
>
> 4 1.597 0 -0.428 2.000000 17.56200 2.00000000 -1.33600000
>
> 5 1.597 0 -0.428 2.236068 40.02114 2.23606798 -0.35329874
>
> 6 1.597 0 -0.428 2.449490 11.22601 2.44948974 0.05388877
>
> X.factor(Sector)Public
>
> 1 1.00000000
>
> 2 1.41421356
>
> 3 1.73205081
>
> 4 2.00000000
>
> 5 2.23606798
>
> 6 2.44948974
>
>
>  On Sat, May 12, 2012 at 6:47 AM, S Ellison <S.Ellison@lgcgroup.com>wrote:
>
>> >I am trying to understand why this line works:
>> >
>> > lm1x = lm(y~X-1, tmp)
>>
>> Well, I would not normally define a data frame element as a matrix myself
>>  (though I might well define a list element as one). But specifying a
>> matrix as the terms part of an lm is documented in lm's details:
>> "If response is a matrix a linear model is fitted separately by
>> least-squares to each column of the matrix"
>>
>> So _something_ will happen.
>>
>> Whether the something is useful depends on the intent.
>>
>> > Here it seems that I was combining the design matrix and the data
>> frame...
>> Did you inspect tmp after adding the design matrix? Was it an odd looking
>> data frame or a list?
>> What seems to have been done is that the design matrix has been added to
>> a list. I wouldn't normally do that if tmp is a data frame, and r would not
>> do so unless the lengths all matched.  But a list should be ok. And lm
>> takes a list or environment as its data argument, so a list of things will
>> work even if they are different types. In other words tmp is just a ragbag
>> of things, each of which lm understands.
>> *******************************************************************
>> This email and any attachments are confidential. Any use, copying or
>> disclosure other than by the intended recipient is unauthorised. If
>> you have received this message in error, please notify the sender
>> immediately via +44(0)20 8943 7000 or notify postmaster@lgcgroup.com
>> and delete this message and any copies from your computer and network.
>> LGC Limited. Registered in England 2991879.
>> Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
>
>
>

	[[alternative HTML version deleted]]

