Method: LMM#drop_fix_ef

Defined in:
lib/mixed_models/LMM.rb

#drop_fix_ef(variable) ⇒ Object

Drop one fixed effect predictor from the model; i.e. refit the model without one predictor variable. Works only if the model was fit via #from_daru or #from_formula.

Arguments

  • variable - name of the fixed effect to be dropped. An interaction effect can be specified as an Array of length two. An intercept term can be denoted as :intercept.

Raises:

  • (NotImplementedError)


1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/mixed_models/LMM.rb', line 1137

def drop_fix_ef(variable)
  raise(NotImplementedError, "LMM#drop_fix_ef does not work if the model was not fit using a Daru::DataFrame") if @from_daru_args.nil?
  raise(ArgumentError, "variable is not one of the fixed effects of the linear mixed model") unless @from_daru_args[:fixed_effects].include? variable

  fe = Marshal.load(Marshal.dump(@from_daru_args[:fixed_effects]))
  variable_ind = fe.find_index variable
  fe.delete_at variable_ind

  return LMM.from_daru(response: @from_daru_args[:response], 
                       fixed_effects: fe,
                       random_effects: @from_daru_args[:random_effects], 
                       grouping: @from_daru_args[:grouping], 
                       data: @from_daru_args[:data],
                       weights: @model_data.weights, 
                       offset: @model_data.offset, 
                       reml: @reml, 
                       start_point: @optimization_result.start_point,
                       epsilon: @optimization_result.epsilon, 
                       max_iterations: @optimization_result.max_iterations, 
                       formula: @formula)
end