Class: Rust::Models::Regression::LinearMixedEffectsModel
- Inherits:
-
RegressionModel
- Object
- RustDatatype
- RegressionModel
- Rust::Models::Regression::LinearMixedEffectsModel
- Defined in:
- lib/rust/models/regression.rb
Overview
Represents a linear mixed effects model in R.
Class Method Summary collapse
- .can_pull?(type, klass) ⇒ Boolean
-
.generate(dependent_variable, fixed_effects, random_effects, data, **options) ⇒ Object
Generates a linear mixed effects model, given its
dependent_variable
andindependent_variables
and itsdata
. - .pull_priority ⇒ Object
- .pull_variable(variable, type, klass) ⇒ Object
Instance Method Summary collapse
Methods inherited from RegressionModel
#actuals, #coefficients, #fitted, #initialize, #load_in_r_as, #method_missing, #model, #mse, #r_hash, #residuals
Methods inherited from RustDatatype
#load_in_r_as, #r_hash, #r_mirror, #r_mirror_to
Constructor Details
This class inherits a constructor from Rust::Models::Regression::RegressionModel
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rust::Models::Regression::RegressionModel
Class Method Details
.can_pull?(type, klass) ⇒ Boolean
177 178 179 |
# File 'lib/rust/models/regression.rb', line 177 def self.can_pull?(type, klass) return type == "S4" && klass == "lmerModLmerTest" end |
.generate(dependent_variable, fixed_effects, random_effects, data, **options) ⇒ Object
Generates a linear mixed effects model, given its dependent_variable
and independent_variables
and its data
. options
can be specified and directly passed to the model.
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/rust/models/regression.rb', line 208 def self.generate(dependent_variable, fixed_effects, random_effects, data, **) Rust.prerequisite("lmerTest") Rust.prerequisite("rsq") random_effects = random_effects.map { |effect| "(1|#{effect})" } RegressionModel.generate( LinearMixedEffectsModel, "lmer", dependent_variable, fixed_effects + random_effects, data, ** ) end |
.pull_priority ⇒ Object
181 182 183 |
# File 'lib/rust/models/regression.rb', line 181 def self.pull_priority 1 end |
.pull_variable(variable, type, klass) ⇒ Object
185 186 187 188 189 |
# File 'lib/rust/models/regression.rb', line 185 def self.pull_variable(variable, type, klass) model = Rust::RustDatatype.pull_variable(variable, Rust::S4Class) return LinearMixedEffectsModel.new(model) end |
Instance Method Details
#r_2 ⇒ Object
224 225 226 227 228 229 |
# File 'lib/rust/models/regression.rb', line 224 def r_2 Rust.exclusive do Rust._eval("tmp.rsq <- rsq(#{self.r_mirror}, adj=F)") return Rust['tmp.rsq'] end end |
#r_2_adjusted ⇒ Object
231 232 233 234 235 236 |
# File 'lib/rust/models/regression.rb', line 231 def r_2_adjusted Rust.exclusive do Rust._eval("tmp.rsq <- rsq(#{self.r_mirror}, adj=T)") return Rust['tmp.rsq'] end end |
#summary ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/rust/models/regression.rb', line 191 def summary unless @summary Rust.exclusive do Rust._eval("tmp.summary <- summary(#{self.r_mirror})") Rust._eval("mode(tmp.summary$objClass) <- \"list\"") Rust._eval("tmp.summary$logLik <- attributes(tmp.summary$logLik)") @summary = Rust["tmp.summary"] end end return @summary end |