Skip to content

Trying to add example that estimates a basic linear regression model using SMM #51

Open
@tyleransom

Description

Hi @floswald, I'm getting more and more familiar with your package and I think it would be great to have some more examples (and, in particular, a regression example).

I've create a gist that attempts to do this. I will happily submit it as a PR to add to the examples if you're interested (and once it actually works!).

My example specifies the following moments to match:

  • E[y'X] in the data and E[y'X] in the model
  • V[y] in data and V[Xβ + ε] in the model (I specified this moment so as to be able to estimate the variance of the error term, like in the MSE formula)

This seems pretty easy to implement, but I am getting a couple of cryptic errors that I can't seem to resolve and was hoping it would be easy for you to spot where I'm going wrong:

  1. Undefined error for dataMomentWd:
┌ Warning: caught exception UndefVarError(:dataMomentWd) at param OrderedDict(:b0 => -0.302835267638089,:b1 => -0.3927639716972684,:b2 => -0.7839915331115677,:b3 => 0.3630821477120001,:s => 1.474363363563423)`
└ @ SMM ~/.julia/packages/SMM/MDWS3/src/mopt/mprob.jl:167
  1. No matter what I set for smpl_iters (it could be 100, 1_000 or 10_000), I always only get back 12 accepted draws

I couldn't see in the example files where dataMomentWd is defined, so that's why I'm getting the undefined error on that in my example.

I also had one other question about SMM in general (since this is my first foray into these types of models):

  • Does one usually simulate the X's in addition to drawing ε and using (X, β, ε) to generate y? The reason I ask is because the X's might have a different dimension than the number of draws of ε, so I can't seem to figure out how to resolve this. For example, suppose I wanted to estimate a regression using the iris data in R and this SMM.jl package. How would I allow for ns [link to a line in the aforementioned gist] to be larger than 150 (the number of rows in iris)?

Thanks a ton for all the help you've given me so far!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions