Johan Sigfrids | 6 May 18:13 2014
Picon

Interactions in GLM

How do you specify interactions and non-linear transforms using the fomula for GLM? Something like y~x1*x2 + x2^2

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Kevin Squire | 12 May 18:43 2014
Picon

Interactions in GLM

I don't think that's supported directly right now. But you can always create additional columns with those values and use them. 

On Tuesday, May 6, 2014, Johan Sigfrids <johan.sigfrids-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

How do you specify interactions and non-linear transforms using the fomula for GLM? Something like y~x1*x2 + x2^2

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
John Myles White | 12 May 18:46 2014
Picon

Re: Interactions in GLM

We might already support interactions, but I'm not sure if it works at the moment.

Non-linear transforms is a trickier case: their use in R depends upon R's willingness to eval() things in arbitrary scopes, which Julia doesn't really do. We can hardcode a few special cases like log, sqrt, etc., but I'm inclined to think it's better to insist that transformations be placed in DataFrames rather than created as temporary columns.

 -- John

On May 12, 2014, at 9:43 AM, Kevin Squire <kevin.squire-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

I don't think that's supported directly right now. But you can always create additional columns with those values and use them. 

On Tuesday, May 6, 2014, Johan Sigfrids <johan.sigfrids <at> gmail.com> wrote:
How do you specify interactions and non-linear transforms using the fomula for GLM? Something like y~x1*x2 + x2^2

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Johan Sigfrids | 12 May 19:06 2014
Picon

Re: Interactions in GLM

I did futz around with the formula but I couldn't get interactions working. I suppose I will just have to start making lots of columns.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Johan Sigfrids | 12 May 19:27 2014
Picon

Re: Interactions in GLM

Follow up question: If you aren't going to support interactions or non-linear terms in the formula, could you support the R thing where you want everything except something like y~.-x7.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Douglas Bates | 13 May 17:34 2014
Picon

Re: Interactions in GLM

Interaction terms are written as A&B not A:B because Colon is already so overloaded.

See the expansion of A*B

julia> using RDatasets

julia> inst = dataset("lme4","InstEval");

julia> ModelFrame(Y ~ Dept*Service, inst).terms
Terms({:Dept,:Service,:(Dept & Service)},{:Y,:Dept,:Service},3x4 Array{Int8,2}:
 1  0  0  0
 0  1  0  1
 0  0  1  1,[1,1,1,2],true,true)

julia> ModelFrame(Y ~ Dept+Service+Dept&Service, inst).terms
Terms({:Dept,:Service,:(Dept & Service)},{:Y,:Dept,:Service},3x4 Array{Int8,2}:
 1  0  0  0
 0  1  0  1
 0  0  1  1,[1,1,1,2],true,true)

On Monday, May 12, 2014 12:27:27 PM UTC-5, Johan Sigfrids wrote:
Follow up question: If you aren't going to support interactions or non-linear terms in the formula, could you support the R thing where you want everything except something like y~.-x7.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Johan Sigfrids | 13 May 22:52 2014
Picon

Re: Interactions in GLM

I've tried all three. both & and *  result in the same error.

using RDatasets, GLM
boston = dataset("MASS", "Boston")

lm(MedV ~ LStat+Age+LStat&Age, boston)


no method getindex(DataFrame, Expr) in coefnames at /Users/johansigfrids/.julia/v0.3/DataFrames/src/formula/formula.jl:249 in coeftable at /Users/johansigfrids/.julia/v0.3/GLM/src/lm.jl:67 in show at /Users/johansigfrids/.julia/v0.3/GLM/src/linpred.jl:77 in anonymous at show.jl:1040 in with_output_limit at show.jl:1017 in showlimited at show.jl:1039 in writemime at replutil.jl:2 in writemime at multimedia.jl:41 in sprint at io.jl:460 in display_dict at /Users/johansigfrids/.julia/v0.3/IJulia/src/execute_request.jl:24

On Tuesday, May 13, 2014 6:34:22 PM UTC+3, Douglas Bates wrote:
Interaction terms are written as A&B not A:B because Colon is already so overloaded.

See the expansion of A*B

julia> using RDatasets

julia> inst = dataset("lme4","InstEval");

julia> ModelFrame(Y ~ Dept*Service, inst).terms
Terms({:Dept,:Service,:(Dept & Service)},{:Y,:Dept,:Service},3x4 Array{Int8,2}:
 1  0  0  0
 0  1  0  1
 0  0  1  1,[1,1,1,2],true,true)

julia> ModelFrame(Y ~ Dept+Service+Dept&Service, inst).terms
Terms({:Dept,:Service,:(Dept & Service)},{:Y,:Dept,:Service},3x4 Array{Int8,2}:
 1  0  0  0
 0  1  0  1
 0  0  1  1,[1,1,1,2],true,true)

On Monday, May 12, 2014 12:27:27 PM UTC-5, Johan Sigfrids wrote:
Follow up question: If you aren't going to support interactions or non-linear terms in the formula, could you support the R thing where you want everything except something like y~.-x7.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Taylor Maxwell | 14 May 03:44 2014
Picon

Re: Interactions in GLM

It works fine for me although I am using the latest master version of GLM so I need to use fit(LmMod, formula,df)

using RDatasets, GLM
boston = dataset("MASS", "Boston")

julia> cc=fit(LmMod,MedV ~ LStat+Age+LStat&Age, boston)
DataFrameRegressionModel{LmMod{DensePredQR{Float64}},Float64}:

Coefficients:
                  Estimate Std.Error    t value Pr(>|t|)
(Intercept)        36.0885   1.46984    24.5528  < eps()
LStat             -1.39212  0.167456   -8.31335  8.8e-16
Age            -0.00072086 0.0198792 -0.0362621   0.9711
LStat & LStat   0.00415595 0.0018518    2.24428   0.0252


On Tuesday, May 6, 2014 10:13:36 AM UTC-6, Johan Sigfrids wrote:
How do you specify interactions and non-linear transforms using the fomula for GLM? Something like y~x1*x2 + x2^2

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Douglas Bates | 14 May 18:04 2014
Picon

Re: Interactions in GLM

I think the problem is with third and higher order interactions.

On Tuesday, May 13, 2014 8:44:38 PM UTC-5, Taylor Maxwell wrote:
It works fine for me although I am using the latest master version of GLM so I need to use fit(LmMod, formula,df)

using RDatasets, GLM
boston = dataset("MASS", "Boston")

julia> cc=fit(LmMod,MedV ~ LStat+Age+LStat&Age, boston)
DataFrameRegressionModel{LmMod{DensePredQR{Float64}},Float64}:

Coefficients:
                  Estimate Std.Error    t value Pr(>|t|)
(Intercept)        36.0885   1.46984    24.5528  < eps()
LStat             -1.39212  0.167456   -8.31335  8.8e-16
Age            -0.00072086 0.0198792 -0.0362621   0.9711
LStat & LStat   0.00415595 0.0018518    2.24428   0.0252


On Tuesday, May 6, 2014 10:13:36 AM UTC-6, Johan Sigfrids wrote:
How do you specify interactions and non-linear transforms using the fomula for GLM? Something like y~x1*x2 + x2^2

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-stats+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane