16 lines
5.1 KiB
Plaintext
16 lines
5.1 KiB
Plaintext
|
|
{
|
||
|
|
"contents" : "#Copyright 2012 The Board of Regents of the University of Wisconsin System.\n#Contributors: Jason Shao, James McCurdy, Enhai Xie, Adam G.W. Halstead,\n#Michael H. Whitney, Nathan DiPiazza, Trey K. Sato and Yury V. Bukhman\n#\n#This file is part of GCAT.\n#\n#GCAT is free software: you can redistribute it and/or modify\n#it under the terms of the GNU Lesser General Public License as published by\n#the Free Software Foundation, either version 3 of the License, or\n#(at your option) any later version.\n#\n#GCAT is distributed in the hope that it will be useful,\n#but WITHOUT ANY WARRANTY; without even the implied warranty of\n#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n#GNU Lesser General Public License for more details.\n#\n#You should have received a copy of the GNU Lesser General Public License \n#along with GCAT. If not, see <http://www.gnu.org/licenses/>.\n########################################################################\n# #\n# <model> class definition and functions. Objects contain equations #\n# and other information for parameterized growth curve models. #\n# #\n########################################################################\nsetClass(\"model\", representation(name = \"character\",\n expression = \"expression\",\n formula = \"formula\",\n guess = \"function\"))\n# Slots:\n# name - a simple description of the model.\n# expression - an object of class \"expression\" that evaluates the response (transformed OD) with respect to the variable Time.\n# formula - same as expression, but with y as the response.\n# guess - a function that computes initial guesses for the parameters given a well object with a valid \"screen.data\" slot\n# containing useable OD values and slope estimates\n# --------------------------------------------------------------------\n###################### BEGIN PROTOTYPING ACCESSOR METHODS##############\n\n# Minh: Let this code fragment be F1.\nif (!isGeneric(\"getName\")){\n if (is.function(\"getName\"))\n fun <- getName\n else\n fun <- function(object) standardGeneric(\"getName\")\n setGeneric(\"getName\", fun)\n}\n# End of F1\nsetMethod(\"getName\", \"model\", function(object) object@name)\n\n# Minh: Let this line be F2.\nsetGeneric(\"getExpression\", function(object){standardGeneric(\"getExpression\")})\n# Question: How is F1 different from F2?\n\nsetMethod(\"getExpression\", \"model\",\n function(object){\n return(object@expression)\n })\n\nsetGeneric(\"getFormula\", function(object){standeardGeneric(\"getFormula\")})\nsetMethod(\"getFormula\", \"model\", \n function(object){\n return(object@formula)\n })\n\nsetGeneric(\"getGuess\", function(object){standeardGeneric(\"getGuess\")})\nsetMethod(\"getGuess\", \"model\", \n function(object){\n return(object@guess)\n })\n######################## ENG PROTOTYPING ########################\n\n# Function to create a new model\n#' Model \n#' \n#' Function to create a new model \n#' @param name The name of the model \n#' @param expression Expression of the model \n#' @param formula The formula of this model \n#' @param guess The guess of this model \n#' @return The new model \nmodel = function(name, expression, formula, guess){\n new(\"model\", name = name, expression = expression, formula = formula, guess = guess)\n}\n\nloess.g = function(well,smooth.param=0.75){\n #data = data.from(well)\n #growth = data[,2]\n #Time = data[,1]\n Time = data.from(well)[,1]\n \n # predicted growth values to be used in estimating growth curve parameters\n loess.fit = loess(data.from(well)[,2]~Time,span=smooth.param)\n t = seq(from = min(Time), to = max(Time), by = (max(Time)-min(Time))/1000)\n y = predict(loess.fit, data.frame(Time=t))\n attr(y,\"names\"
|
||
|
|
"created" : 1425419995370.000,
|
||
|
|
"dirty" : false,
|
||
|
|
"encoding" : "UTF-8",
|
||
|
|
"folds" : "",
|
||
|
|
"hash" : "2225975310",
|
||
|
|
"id" : "992E3490",
|
||
|
|
"lastKnownWriteTime" : 1425511077,
|
||
|
|
"path" : "~/Documents/GCAT4/trunk/R/GCAT/R/class.model.R",
|
||
|
|
"project_path" : "R/class.model.R",
|
||
|
|
"properties" : {
|
||
|
|
},
|
||
|
|
"source_on_save" : false,
|
||
|
|
"type" : "r_source"
|
||
|
|
}
|