# Syntax difficulties with LM for ordinary least squares

13 messages
Open this post in threaded view
|

## Syntax difficulties with LM for ordinary least squares

 Hi,I'm trying to do the simplest linear model, OLS regression of X1=[2,4,6] on X2=[1,2,3] and an intercept (the intercept estimate should be 0, the slope estimate should be 2), and obtain t-statistics and R-squared. Here are four commands that ideally would work, yet only one of them is successful:# Setupusing GLMusing DataFramesx1 = [2,4,6]x2 = [1,2,3]# Version 1: Succeedsjulia> A = DataFrame(hcat(x1,x2))julia> lm(x1 ~ x2, A)Coefficients: Estimate Std.Error t value Pr(>|t|) (Intercept) 2.56395e-15 2.44585e-15 1.04828 0.4850 x2 2.0 1.13221e-15 1.76646e15 <1e-15# Version 2: Failsjulia> A = DataFrame(hcat(x1,x2))julia> lm(A[:x1] ~ A[:x2]) ERROR: `lm` has no method matching lm(::Formula)# Version 3: Failsjulia> A = DataFrame(hcat(x1,x2))julia> lm(A[:x2], A[:x1]) ERROR: `fit` has no method matching fit(::Type{LinearModel{T<:LinPred}}, ::DataArray{Int64,1}, ::DataArray{Int64,1}) in lm at /.../.julia/v0.3/GLM/src/lm.jl:43# Version 4: Failsjulia> lm(x2,x1) ERROR: `fit` has no method matching fit(::Type{LinearModel{T<:LinPred}}, ::Array{Int64,1}, ::Array{Int64,1}) in lm at /.../.julia/v0.3/GLM/src/lm.jl:43Is it supposed to be this way? Shouldn't there at least be support for lm(X,y) where X and y are Floats? linreg(X,y) works but doesn't have the desired hypothesis tests. lm says it has method lm(X,y), yet Version 4 above didn't work:julia> methods(lm) # 3 methods for generic function "lm": lm(e::Expr,df,args...) at /.../.julia/v0.3/GLM/src/deprecated.jl:6 lm(s::String,df,args...) at /.../.julia/v0.3/GLM/src/deprecated.jl:12 lm(X,y) at /.../.julia/v0.3/GLM/src/lm.jl:43Thanks,Bradley -- 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 [hidden email]. For more options, visit https://groups.google.com/d/optout.
Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

 In reply to this post by Bradley Setzler On Tuesday, August 26, 2014 10:34:12 AM UTC-5, Bradley Setzler wrote:Thanks, I would prefer to do it that way, but my lack of programming experience has kept me from contributing. [...] I want to be a contributor to the Julia community, but admittedly I need the for-dummies version to start. Ideally I would want to see a step-by-step guide to modifying and testing packages locally before submitting the pull request. Do any resources like that exist? These are probably very easy things, but keep in mind that I literally taught myself computing this year and still have a lot to learn.I may need to write (...or convince someone else to write...) a page or two cheat sheet like that in the next few weeks. I'll ping you when it's done. -- 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 [hidden email]. For more options, visit https://groups.google.com/d/optout.
Open this post in threaded view
|

## Re: Syntax difficulties with LM for ordinary least squares

 If someone writes up a guide, I'm happy to edit it.One point: packages in Julia are just a pile of code found in a specific directory. They're just structured according to conventions that allow them to loaded automatically.Specifically, if I type using Foo, then Julia looks in ~/.julia/v0.3/Foo/src for a file called Foo.jl and attempts to include that file as well as import all of the exports from the module Foo. Julia assumes a Foo module is defined inside of the Foo.jl file, which is why the exports are imported.That description may be subtle (and UNIX-centric), but it is almost the entirety of what you need to know to make changes to packages locally. Submitting those changes for review requires some understanding of git and GitHub, but the generic guides for working with GitHub are better than anything we'd produce. -- JohnOn Aug 26, 2014, at 9:09 AM, Gray Calhoun <[hidden email]> wrote:On Tuesday, August 26, 2014 10:34:12 AM UTC-5, Bradley Setzler wrote:Thanks, I would prefer to do it that way, but my lack of programming experience has kept me from contributing. [...] I want to be a contributor to the Julia community, but admittedly I need the for-dummies version to start. Ideally I would want to see a step-by-step guide to modifying and testing packages locally before submitting the pull request. Do any resources like that exist? These are probably very easy things, but keep in mind that I literally taught myself computing this year and still have a lot to learn.I may need to write (...or convince someone else to write...) a page or two cheat sheet like that in the next few weeks. I'll ping you when it's done. -- 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 [hidden email]. 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 [hidden email]. For more options, visit https://groups.google.com/d/optout.
Open this post in threaded view
|