Well, the analogWrite takes a parameter for the PWM that spans from 0 to 255.
So, you need a variable for the pwm and some logic for setting it correctly.
Linear relationships between two values can often be best solved by the map()
//example code for the thermistor problem
int temp = getTempFromThermistor();
int value = map(temp , minTemp, maxTemp, 0, 255); //this line maps the temperature from the range [minTemp,maxTemp] to the range [0,255]
When you need time to be a part of the equation, you need to use millis() in addition to the previous guidelines.
A specific problem would be easier to help..