Skip to content

Commit

Permalink
vignette clean-up and version/date updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kkholst committed Dec 20, 2023
1 parent 71cca32 commit ef796aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 157 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: lava
Type: Package
Title: Latent Variable Models
Version: 1.7.4
Date: 2023-12-10
Date: 2023-12-20
Authors@R: c(person("Klaus K.", "Holst", email="klaus@holst.it", role=c("aut", "cre")),
person("Brice", "Ozenne", role = "ctb"),
person("Thomas", "Gerds", role = "ctb"))
Expand Down
14 changes: 3 additions & 11 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# lava 1.7.4
Development version

- New methods `estimate.mlm`, `IC.mlm`, `pars.mlm`, `estimate.array`, `estimate.data.frame`
- `Print` method for nicer print of tabular data (matrix, data.frame)
- `merge` regex
- `IC` should generally return row-names (default id) as obtained from model.matrix or similar
- TODO:
+ Rewrite DESCRIPTION/lava-package.Rd
+ Update README to reflect current state of package
+ IF vignette
+ Update help pages for merge, estimate, IC, ...

- `Print` method for tabular data (matrix, data.frame)
- `merge` now supports regular expressions
- `IC` returns row-names (default id) as obtained from model.matrix or similar

# lava 1.7.3
- `parameter.estimate` method to extract matrix with estimates, standard errors, and confidence limits from and estimate object (coefmat element)
Expand Down
151 changes: 6 additions & 145 deletions vignettes/influencefunction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ knitr::opts_chunk$set(
\newcommand{\Pz}{P_{0}}
\newcommand{\op}{o_{P}}

# TODO

- Quantile regression and Zeng&Lin procedure?
- Diagnostics Cohen's Kappa, partial gamma example
- method argument to estimate (Richardson vs complex)
- Explain that the `type` argument is important (first example): it defines the
target parameter and the influence function
- survival example in transformation section (delta method)
- Need to elaborate on the baseline and time argument. Add documentation to
IC.phreg and reference to that perhaps since these arguments are not documented
in lava and not required arguments for the IC S3method


# Influence functions

Estimators that have parametric convergence rates can often be fully
Expand Down Expand Up @@ -356,7 +343,7 @@ semfit <- estimate(sem, data = dw)
estimate(semfit)
```

## TODO Example: quantile
## Example: quantile

Let \(\beta\) denote the \(\tau\)th quantile of \(X\), with IF
\begin{align*}
Expand All @@ -365,7 +352,7 @@ Let \(\beta\) denote the \(\tau\)th quantile of \(X\), with IF

where \(f_{0}\) is the density function of \(X\).

To calculate the variance estimate an estimate of the density is needed which can be
To calculate the variance estimate, an estimate of the density is thus needed which can be
obtained by a kernel estimate. Alternatively,
the resampling method of [@zenglin2008] can be applied.
Here we use a kernel smoother (additional arguments to the `estimate` function
Expand Down Expand Up @@ -888,146 +875,20 @@ ea
IC(ea) |> head()
```

## TODO: Example: Average Treatment Effects

## Example: Average Treatment Effects

```{r targeted, cache=TRUE}
a1 <- targeted::cate(a ~ 1,
data = dw,
response_model = y1 ~ x1+w+a,
propensity_model = a ~ x1*w
)
a1
IC(a1) |> head()
```

<!-- ```{r targeted2, cache=TRUE} -->
<!-- targeted::cate(a ~ w, -->
<!-- data = dw, -->
<!-- response_model = targeted::ML(y1 ~ x1+w+a, "xgboost.binary"), -->
<!-- propensity_model = targeted::ML(a ~ x1*w, "xgboost.binary") -->
<!-- ) -->
<!-- ``` -->



- `targeted::cate`
- `targeted::riskreg`
- `targeted::alean`
- `targeted::riskreg_surv`
- `mets::binregTSR`
- `mets::binregATE`
- `mets::logitATE`
- `mets::doubleFGR`
- `mets::resmeanATE`
- `mets::recregIPCW`
- `mets::recurrentMarginalAIPCWdata_`
- `mets::normalATE`
- `mets::binregATEbin`
- `mets::mediatorSurv`
- ...

## TODO: Two-stage estimation

```{r stack}
stack
```


### TODO: Measurement error

```{r measurementerror}
measurement.error
```


# TODO: Examples diagnostics and ....

- diagtest
- assoc, riskcomp Ratio, Diff, odds, OR,
- information_assoc, information.table, independence (not exported) - information.multinomial
- gkgamma, kappa

Example [@mckenzie1996; @clarke1993]

50 patients from Monash Medical Centre, Melbourne
- *Diagnosis of depression* (DSM-III-R MDD, Dysthymia, Adjustment
Disorder with Depressed Mood, Depression NOS)
- *Beck Depression Inventory (BDI)* (Beck et al., 1961)
- *General Health Questionnaire (GHQ)* (Goldberg & Williams, 1988)
(classification, see McKenzie, 1992).

| Diagnosis | BDI | GHQ | n |
|-----------+-----+-----+----|
| \(+\) | 1 | 1 | 7 |
| \(-\) | 1 | 1 | 1 |
| \(-\) | 1 | 0 | 1 |
| \(+\) | 0 | 1 | 4 |
| \(-\) | 0 | 1 | 2 |
| \(+\) | 0 | 0 | 2 |
| \(-\) | 0 | 0 | 33 |

Agreement between a diagnosis of depression,
and caseness according to the screening test?

Let \(X\in\{0,1,...,k-1\}\) and \(Y\in\{0,1,...,l-1\}\)
be categorical s.v. with the joint probabilities \(\bm{\pi}\) and data \(\bm{n}\)

\begin{align*}
\pi_{ij} = \pr(X=i,Y=j), \qquad
\bm{n}=
\begin{pmatrix}
n_{11} & n_{12} & \cdots & n_{1l} \\
n_{21} & n_{22} & \cdots & n_{2l} \\
\vdots & \vdots & \ddots & \vdots \\
n_{k1} & n_{k2} & \cdots & n_{kl}
\end{pmatrix}
\end{align*}
\vspace*{-.5em}
and association measure
# (twice continuous differentiable)
\begin{align*}
\alpha = \alpha(\bm{\pi}).
\end{align*}

We will assume that we have an asymptotically linear estimator of
\(\bm{\pi} = \bm{\pi}(\theta)\) ,
e.g., under multinomial distribution with likelihood
\begin{align*}
L(\pi_{ij}\mid n_{ij}) = A\prod_{i,j} \pi_{ij}^{n_{ij}}, \pi_{ij}\geq 0, \sum_{ij}\pi_{ij}=1
\end{align*}
\begin{align*}
\widehat{\pi}_{ij} = \frac{n_{ij}}{\sum_{i,j}n_{ij}}, \quad \widehat{\alpha} = \alpha(\widehat{\bm{\pi}})
\end{align*}


- estimate.array
- multinomial

# TODO: Enabling new models

- IC method
- score method

```{r minimal}
minimal <- lvm(c(y1, y2, y3) ~ x) |>
distribution(~ id1 + id2 + id3, value = list(c(1, 2, 3, 4, 5), c(1, 1, 2, 2, 2), c(1, 2, 6, 7, 8))) |>
distribution(~ y1 + y2 + y3, value = binomial.lvm()) |>
sim(5, seed = 123)
l1 <- glm(y1~x,family=binomial,data=minimal)
l2 <- glm(y2~x,family=binomial,data=minimal)
l3 <- glm(y3~x,family=binomial,data=minimal)
merge(l1, l2, l3) |> iid()
merge(l1, l2, l3, id=NULL) |> iid()
g <- merge(l1, l2, l3, id = with(minimal, list(id1, id2, id3)))
iid(g)
g
estimate(l2, id = minimal$id2) |> IC()
ii <- IC(l2)
```

# SessionInfo

```{r sessionInfo}
Expand Down

0 comments on commit ef796aa

Please sign in to comment.