Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fit_discrete_mc #681

Merged
merged 6 commits into from
Jan 6, 2023
Merged

Add fit_discrete_mc #681

merged 6 commits into from
Jan 6, 2023

Conversation

Smit-create
Copy link
Member

@Smit-create Smit-create requested review from jstac and oyamad January 2, 2023 04:28
@coveralls
Copy link

coveralls commented Jan 2, 2023

Coverage Status

Coverage: 92.815% (+0.03%) from 92.782% when pulling 55b6c9e on Smit-create:i-678 into 147d862 on QuantEcon:main.

Copy link
Member

@oyamad oyamad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Smit-create

  • This part is missing:
    # Assign the visited states in the cartesian product as the state values
    prod = cartesian(V, order=order)
    mc.state_values = prod[mc.state_values]
  • Add tests
  • Examples section will be helpful

There are a few points open for discussion:

  • What shape should X be of?
  • Is the name S of the second argument appropriate?
  • Is this for approximation or estimation (which of approximation.py or estimate.py to include this code in)?

@jstac
Copy link
Contributor

jstac commented Jan 2, 2023

Thanks for the review @oyamad .

I think this should be in estimate.py because there is no specified model to approximate. I suggest a better name for S is grids.

I am away from my computer so I won't give further feedback. @Smit-create , it would be great if you could coordinate with @oyamad to finish this PR.

@Smit-create
Copy link
Member Author

There are a few points open for discussion:

  • What shape should X be of?
  • Is the name S of the second argument appropriate?
  • Is this for approximation or estimation (which of approximation.py or estimate.py to include this code in)?

Thanks, @oyamad. I have addressed these questions and added the missing part. If the current diff looks good, I can start working on Examples and tests.

@oyamad
Copy link
Member

oyamad commented Jan 2, 2023

  • Regarding the shape of X, I would prefer to follow the convention in estimate_mc(X) and cartesian_nearest_index(X, ...) where X is supposed to be a T x n array with X[t] containing the t-th observation. What do you think?
  • For the second argument, I would follow the suggestion from @jstac (plural grids).

@Smit-create
Copy link
Member Author

  • where X is supposed to be a T x n array

I kept it as n x T because the output of simulate_linear_model is n x T, moreover, one can easily think of this as horizontally stacked individual vectors of shape n x 1.

I would follow the suggestion from

Sure will change that.

@jstac
Copy link
Contributor

jstac commented Jan 2, 2023

I kept it as n x T because the output of simulate_linear_model is n x T

Both @oyamad and @Smit-create 's opinions are sensible on this point.

Another option --- combining these opinions but with a breaking change --- is to convert linear_state_space so that its output is $T \times n$.

This is more work but I personally prefer it, so that we have consistency across all of these functions.

@Smit-create Smit-create requested a review from oyamad January 3, 2023 07:10
Copy link
Member

@oyamad oyamad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When n=1, it is supposed to pass for example X = [[0.1], [0.6], [1.2], [0.2]] and grids = ([0., 0.5, 1.],). Is there any clever way to detect this case and allow passing X = [0.1, 0.6, 1.2, 0.2] and grids = [0., 0.5, 1.]?

@Smit-create
Copy link
Member Author

Is there any clever way to detect this case

Thanks for the review. I am not sure if we should support this as we are clearly expecting the input shape of T X n which is independent of n. IMHO, it is good to keep it unchanged regarding this.

@Smit-create Smit-create requested a review from oyamad January 5, 2023 06:13
Copy link
Member

@oyamad oyamad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Smit-create Thanks!

@oyamad oyamad merged commit 65ac63d into QuantEcon:main Jan 6, 2023
@jstac
Copy link
Contributor

jstac commented Jan 6, 2023

Many thanks @Smit-create and @oyamad

@Smit-create Smit-create deleted the i-678 branch January 6, 2023 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants