4141# ' * For `backend = "rstan"`, arguments are passed to [rstan::sampling()]
4242# ' or [rstan::optimizing()].
4343# ' * For `backend = "cmdstanr"`, arguments are passed to the
44- # ' [`$sample()`](https://mc-stan.org/cmdstanr/reference/model-method-sample.html)
45- # ' or
46- # ' [`$optimize()`](https://mc-stan.org/cmdstanr/reference/model-method-optimize.html)
47- # ' methods of the
48- # ' [CmdStanModel](https://mc-stan.org/cmdstanr/reference/CmdStanModel.html)
49- # ' class.
44+ # ' [`$sample()`][cmdstanr::sample()] or
45+ # ' [`$optimize()`][cmdstanr::optimize()] methods of the
46+ # ' [CmdStanModel][cmdstanr::CmdStanModel] class.
5047# '
5148# ' @concept Bayesian
5249# ' @concept DCM
5350# ' @concept Stan
51+ # ' @concept Cmd
52+ # ' @concept Model
5453# '
5554# ' @returns A `measrdcm` object.
5655# ' @export
@@ -173,8 +172,8 @@ dcm_estimate <- function(dcm_spec, data, missing = NA, identifier = NULL,
173172# ' @param backend The name of the backend used to fit the model.
174173# ' @param model The fitted Stan model. This will object of class
175174# ' [rstan::stanfit-class] if `backend = "rstan"` and
176- # ' [`CmdStanMCMC`](https://mc-stan.org/ cmdstanr/reference/ CmdStanMCMC.html)
177- # ' if `backend = "cmdstanr"` was specified when fitting the model.
175+ # ' [`CmdStanMCMC`][ cmdstanr:: CmdStanMCMC] if `backend = "cmdstanr"` was
176+ # ' specified when fitting the model.
178177# ' @param respondent_estimates An empty list for adding estimated person
179178# ' parameters after fitting the model.
180179# ' @param fit An empty list for adding model fit information after fitting the
@@ -194,7 +193,7 @@ dcm_estimate <- function(dcm_spec, data, missing = NA, identifier = NULL,
194193measrfit <- S7 :: new_class(" measrfit" , package = " measr" ,
195194 properties = list (
196195 model_spec = S7 :: new_property(
197- class = S7 :: S7_object ,
196+ class = S7 :: class_any ,
198197 setter = function (self , value ) {
199198 if (! is.null(self @ model_spec )) {
200199 stop(" @model_spec is read-only" , call. = FALSE )
@@ -214,8 +213,7 @@ measrfit <- S7::new_class("measrfit", package = "measr",
214213 }
215214 ),
216215 stancode = S7 :: new_property(
217- class = S7 :: new_S3_class(class = c(" glue" , " character" )),
218- default = glue :: glue(),
216+ class = S7 :: class_character ,
219217 setter = function (self , value ) {
220218 if (! is.null(self @ stancode )) {
221219 stop(" @stancode is read-only" , call. = FALSE )
@@ -226,7 +224,7 @@ measrfit <- S7::new_class("measrfit", package = "measr",
226224 ),
227225 method = S7 :: new_property(
228226 class = stanmethod ,
229- default = optim() ,
227+ default = NULL ,
230228 setter = function (self , value ) {
231229 if (! is.null(self @ method )) {
232230 stop(" @method is read-only" , call. = FALSE )
@@ -247,7 +245,7 @@ measrfit <- S7::new_class("measrfit", package = "measr",
247245 ),
248246 backend = S7 :: new_property(
249247 class = stanbackend ,
250- default = rstan() ,
248+ default = NULL ,
251249 setter = function (self , value ) {
252250 if (! is.null(self @ backend )) {
253251 stop(" @backend is read-only" , call. = FALSE )
@@ -325,8 +323,59 @@ measrfit <- S7::new_class("measrfit", package = "measr",
325323 }
326324)
327325
326+ # ' S7 class for measrdcm objects
327+ # '
328+ # ' The `measrdcm` constructor is exported to facilitate the conversion of other
329+ # ' model objects (e.g., `stanfit`) to `measrdcm` objects. We do not expect or
330+ # ' recommend calling this function directly, unless you are creating a method
331+ # ' for converting to `measrdcm`. Rather, to create a `measrdcm` object, one
332+ # ' should use [dcm_estimate()].
333+ # '
334+ # ' @param model_spec The model specification used to estimate the model.
335+ # ' @param data The data used to estimate the model.
336+ # ' @param stancode The model code in *Stan* language.
337+ # ' @param method The method used to fit the model.
338+ # ' @param algorithm The name of the algorithm used to fit the model.
339+ # ' @param backend The name of the backend used to fit the model.
340+ # ' @param model The fitted Stan model. This will object of class
341+ # ' [rstan::stanfit-class] if `backend = "rstan"` and
342+ # ' [`CmdStanMCMC`][cmdstanr::CmdStanMCMC] if `backend = "cmdstanr"` was
343+ # ' specified when fitting the model.
344+ # ' @param respondent_estimates An empty list for adding estimated person
345+ # ' parameters after fitting the model.
346+ # ' @param fit An empty list for adding model fit information after fitting the
347+ # ' model.
348+ # ' @param criteria An empty list for adding information criteria after fitting
349+ # ' the model.
350+ # ' @param reliability An empty list for adding reliability information after
351+ # ' fitting the model.
352+ # ' @param file Optional name of a file which the model objects was saved to
353+ # ' or loaded from.
354+ # ' @param version The versions of measr, *Stan*, and rstan or cmdstanr that were
355+ # ' used to fit the model.
356+ # '
357+ # ' @concept Stan
358+ # '
359+ # ' @returns A `measrdcm` object.
360+ # ' @seealso [dcm_estimate()].
361+ # ' @export
362+ # '
363+ # ' @examples
364+ # ' qmatrix <- tibble::tibble(
365+ # ' att1 = sample(0:1, size = 15, replace = TRUE),
366+ # ' att2 = sample(0:1, size = 15, replace = TRUE),
367+ # ' att3 = sample(0:1, size = 15, replace = TRUE),
368+ # ' att4 = sample(0:1, size = 15, replace = TRUE)
369+ # ' )
370+ # '
371+ # ' spec <- dcm_specify(qmatrix = qmatrix)
372+ # '
373+ # ' measrdcm(spec)
328374measrdcm <- S7 :: new_class(" measrdcm" , parent = measrfit , package = " measr" ,
329375 properties = list (
330- model_spec = S7 :: new_property(class = dcmstan :: dcm_specification )
376+ model_spec = S7 :: new_property(
377+ class = dcmstan :: dcm_specification ,
378+ default = NULL
379+ )
331380 )
332381)
0 commit comments