-
Notifications
You must be signed in to change notification settings - Fork 3
feat(coef.estimate): tests for s3 method + setting options.lava(messages = 1) by default #23
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
Open
benesom
wants to merge
4
commits into
develop
Choose a base branch
from
chore/cast-warning-coef-estimate-benesom
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,6 +96,13 @@ To cite that `lava` package please use one of the following references | |
|
|
||
| ## Examples | ||
|
|
||
| The package uses the `message` function to provide additional | ||
| information to users. All messages can be disabled session-wide with | ||
|
|
||
| ``` r | ||
| lava.options(messages = 0) # the default is 1 | ||
| ``` | ||
|
|
||
| ### Influence functions | ||
|
|
||
| Construct `estimate` objects from parameter coefficients and estimated | ||
|
|
@@ -119,22 +126,22 @@ distribution via their estimated influence functions | |
| ``` r | ||
| e <- c(a, b) | ||
| vcov(e) # joint distribution | ||
| #> a b | ||
| #> a 0.1023667491 0.0001747415 | ||
| #> b 0.0001747415 0.0625808426 | ||
| #> a b | ||
| #> a 0.07280218 0.03491347 | ||
| #> b 0.03491347 0.24018309 | ||
| summary(e, null=c(0, 0)) | ||
| #> Call: estimate.default(contrast = as.list(seq_along(p)), null = ..1, | ||
| #> Call: estimate.default(f = FALSE, contrast = contrast, null = ..1, | ||
| #> vcov = vcov(object, messages = 0), coef = p) | ||
| #> ──────────────────────────────────────────────────────────── | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.5 0.3199 -0.1271 1.127 0.118111 | ||
| #> b 0.8 0.2502 0.3097 1.290 0.001384 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.5 0.2698 -0.02884 1.029 0.06387 | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kkholst , I assume that we forgot to render the readme file during previous changes, because I don't see how the current changes would cause these estimates to change. |
||
| #> b 0.8 0.4901 -0.16055 1.761 0.10260 | ||
| #> ──────────────────────────────────────────────────────────── | ||
| #> Null Hypothesis: | ||
| #> [a] = 0 | ||
| #> [b] = 0 | ||
| #> | ||
| #> chisq = 12.6472, df = 2, p-value = 0.001793 | ||
| #> chisq = 4.8386, df = 2, p-value = 0.08899 | ||
| ``` | ||
|
|
||
| Parameter transformations can be calculated directly as in the following | ||
|
|
@@ -144,64 +151,61 @@ Products | |
|
|
||
| ``` r | ||
| a * b | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.4 0.2851 -0.1588 0.9588 0.1607 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.4 0.3668 -0.319 1.119 0.2755 | ||
| ``` | ||
|
|
||
| General transformations | ||
|
|
||
| ``` r | ||
| (3 * cos(a) / sqrt(b) + 1) / a^2 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 15.77 22.33 -27.98 59.53 0.4798 | ||
| #> a 15.77 20.02 -23.46 55.01 0.4307 | ||
| ``` | ||
|
|
||
| Inner product, sums, and products | ||
|
|
||
| ``` r | ||
| c(iprod=e %*% c(a, b^2), sum=sum(e), prod=prod(e)) | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> iprod 0.762 0.5777 -0.3703 1.8943 0.187160 | ||
| #> ───── | ||
| #> sum 1.300 0.4066 0.5031 2.0969 0.001386 | ||
| #> ───── | ||
| #> prod 0.400 0.2851 -0.1588 0.9588 0.160658 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> iprod 0.762 1.0451 -1.28640 2.810 0.46594 | ||
| #> sum 1.300 0.6187 0.08733 2.513 0.03563 | ||
| #> prod 0.400 0.3668 -0.31899 1.119 0.27554 | ||
| ``` | ||
|
|
||
| Exponentiation and renaming of parameter | ||
|
|
||
| ``` r | ||
| c(pow = a^b) | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> pow 0.5743 0.3102 -0.03368 1.182 0.06411 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> pow 0.5743 0.272 0.04118 1.108 0.03474 | ||
| ``` | ||
|
|
||
| Transformation and subsetting | ||
|
|
||
| ``` r | ||
| c(e["a"] * e["b"] / a, e["b"]) | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.8 0.2502 0.3097 1.29 0.001384 | ||
| #> ─ | ||
| #> b 0.8 0.2502 0.3097 1.29 0.001384 | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> a 0.8 0.4901 -0.1605 1.761 0.1026 | ||
| #> b 0.8 0.4901 -0.1605 1.761 0.1026 | ||
| ``` | ||
|
|
||
| For the `%*%*` operator we can also use a general contrast matrix | ||
|
|
||
| ``` r | ||
| B <- rbind(c(1,-1), c(1,0), c(0,1)) | ||
| B %*% e | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> [a] - [b] -0.3 0.4057 -1.0952 0.4952 0.459634 | ||
| #> [a] 0.5 0.3199 -0.1271 1.1271 0.118111 | ||
| #> [b] 0.8 0.2502 0.3097 1.2903 0.001384 | ||
| #> | ||
| #> Null Hypothesis: | ||
| #> Estimate Std.Err 2.5% 97.5% P-value | ||
| #> [a] - [b] -0.3 0.4931 -1.26648 0.6665 0.54293 | ||
| #> a 0.5 0.2698 -0.02884 1.0288 0.06387 | ||
| #> b 0.8 0.4901 -0.16055 1.7605 0.10260 | ||
| #> ──────────────────────────────────────────────────────────── | ||
| #> Null Hypothesis: | ||
| #> [a] - [b] = 0 | ||
| #> [a] = 0 | ||
| #> [b] = 0 | ||
| #> | ||
| #> chisq = 12.6472, df = 2, p-value = 0.001793 | ||
| #> chisq = 4.8386, df = 2, p-value = 0.08899 | ||
| plot(B %*% e) | ||
| ``` | ||
|
|
||
|
|
@@ -218,7 +222,7 @@ regression(m) <- z1 + z2 + z3 ~ u2 | |
| latent(m) <- ~ u1 + u2 | ||
| regression(m) <- u2 ~ u1 + x | ||
| regression(m) <- u1 ~ x | ||
|
|
||
| plot(m) | ||
| ``` | ||
|
|
||
|
|
@@ -358,7 +362,7 @@ onerun <- function(...) { | |
| } | ||
| val <- sim(onerun, 100) | ||
| summary(val, estimate=1:4, se=5:8, short=TRUE) | ||
| #> 100 replications Time: 2.457s | ||
| #> 100 replications Time: 2.641s | ||
| #> | ||
| #> Total.Estimate Direct.Estimate Indirect.Estimate S~x~z.Estimate | ||
| #> Mean 1.99533 1.00468 0.99066 0.99066 | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump to 3.2.0 because
expect_no_message()became stable.