### mPRM (Modified Panel Regression Model) ###
# mPRM is an extension of Costello et al. 2012 intended for highly data limited fisheries. It was develoepd for use on the simulated datasets produced by the FAO Technical Report "Developing new approaches to global stock status assessment and maximum sustainable production of the seas" (Rosenberg et al. n.d.)
#Developed by Dan Ovando 9/13/13

### Formatting Data ###
#CatchHistory should be a N by 4 data frame with colnames c('id','idname','year','catch','linf')
# id=numeric id number
# idname= character id name
# year= year index of catch (doesnt matter what this is, 1,2,3, 2001,2002,2003,etc.)
# catch= catch
# linf = either 30,70,or 150. Linf is in fact a proxy for species category, such that Linf must be one of 30 (small pelagic), 70 (demersal), or 150 (large pelagic). 


rm(list=ls())
setwd('/Users/danovando/Desktop/Bren/SFG Work/The Method/CI Working Group/R Code for FAO Report')
source('mPRM Functions.R')
load('mPRM.Rdata')

CatchHistory<- read.csv('Sample Catch.csv') #load in appropriately formatted catch history

Results<- mPRM(CatchHistory,CostelloInputs)

head(Results)

#Results has three compotentns, Individual, Group, and RawData
#Individual has the year by year predictions for each individual stock in the dataset
#Group has the year by yera median B/Bmsy for the group of fisheries in the dataset
#RawData has the raw data calculated each year for each individual fishery

