;; ;; Put this file in the Extras directory in the directory in ;; which you start Arc. ;; Source: http://www.stat.umn.edu/arc ;; ;;; ;;; An inverse gaussian glim-proto; automatically adds to R-code menus ;;; when loaded. ;;; ;;; $Revision 1.0$ ; define prototype (defproto invgaussreg-proto () () glim-proto) ; initial estimates (defmeth invgaussreg-proto :initial-means () (send self :yvar)) ; this model has a scale factor (defmeth invgaussreg-proto :estimate-scale () t) ; define the variance as a function of the mean (defmeth invgaussreg-proto :fit-variances (mu) (^ mu 3)) ; compute the deviance at mu (defmeth invgaussreg-proto :fit-deviances (mu) (let* ((y (send self :yvar)) (pw (send self :pweights)) (raw-dev (/ (^ (- y mu) 2) (* mu mu y)))) (if pw (* pw raw-dev) raw-dev))) ; define the inverse-square link (defproto invsq-link () () glim-link-proto) ; compute the linear predictor given mu (the link function) (defmeth invsq-link :eta (mu) (/ (^ mu 2))) ; compute mu given the linear predictor (the kernel mean function) (defmeth invsq-link :means (eta) (/ (sqrt eta))) ; compute first derivatives. (defmeth invsq-link :derivs (mu) (/ -2 (^ mu 3))) ; add a glm menu item to fit these models. (arc-glm-method :menu-item 'fit-invgauss-menu-item :menu-title "Fit Inv-Gaussian response..." :fitname :invgauss :mean-functions (list "Inv sqrt" "Identity" "Exponential") :link-functions (list invsq-link identity-link log-link) :proto 'invgaussreg-proto)